import request from '@/utils/request'
import { member,qywx } from 'api/baseUrl'
const user = member + '/user'
const menu = member + '/menu'

export function login(params) {
  return request({
    url: user + '/login',
    method: 'get',
    params
  })
}

/**
 * 企业微信登录
 */
export function qiyeWechatLogin() {
  return request({
    url: qywx + '/pcAuth2qywx',
    method: 'get'
  })
}

/**
 * 企业微信登录校验
 */
export function qiyeWechatLoginVerify(params) {
  return request({
    url: user + '/qywxPcLogin?' + params,
    method: 'get'
  })
}

/**
 * 企业微信通讯录
 */
export function getContactList() {
  return request({
    url: qywx + '/getContactList',
    method: 'get'
  })
}


export function getInfo() {
  return request({
    url: user + '/getMyUserInfo',
    method: 'get',
  })
}

//根据用户获取角色列表
export function getUserRoles(params) {
  return request({
    url: user + '/getUserRoleList',
    method: 'get',
    params
  })
}

export function logout() {
  return request({
    url: user + '/logout',
    method: 'post'
  })
}


export function userUpdate(data) {
  return request({
    url: user + '/updateMyUserInfo',
    method: 'post',
    data
  })
}

export function userPassword(data) {
  return request({
    url: user + '/modifyMyPassword',
    method: 'post',
    data
  })
}

export function uploadAvatar(data) {
  return request({
    url: user + '/uploadAvatar',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

// 获取我的权限菜单
export function menuList() {
  return request({
    url: menu + '/getMenuList',
    method: 'get',
  })
}


// 获取手机验证码
export function getMobileValideCode(params) {
  return request({
    url: user + '/getMobileValideCode',
    method: 'get',
    params
  })
}

// 根据手机获取企业列表
export function getCorpAccountByMobile(params) {
  return request({
    url: user + '/getCorpAccountByMobile',
    method: 'get',
    params
  })
}

// 手机号登录
export function loginByMobile(params) {
  return request({
    url: user + '/loginByMobile',
    method: 'get',
    params
  })
}

// 手机号验证码校验
export function checkMobileValideCode(params) {
  return request({
    url: user + '/checkMobileValideCode',
    method: 'get',
    params
  })
}

// 通过验证码修改手机号
export function modifyUserMobile(data) {
  return request({
    url: user + '/modifyUserMobile',
    method: 'post',
    data
  })
}

// 通过验证码重置密码
export function setPasswordByMobileValideCode(data) {
  return request({
    url: user + '/setPasswordByMobileValideCode',
    method: 'post',
    data
  })
}
